package com.clkj.xiuzheng.dao;

import com.clkj.xiuzheng.pojo.Product;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.BaseMapper;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface ProductMapper extends Mapper<Product> {
    @Select("SELECT * FROM t_cl_product WHERE product_status = 0   AND  product_name LIKE '%${name}%'  order by product_name asc ")
    List<Product> queryProduct(@Param("name") String name);

    @Select("SELECT * FROM t_cl_product WHERE product_status = 0  order by product_name asc ")
    List<Product> selectAllProduct();

    @Update("update t_cl_product set product_num = product_num + #{productNum} where product_id = #{productId}")
    void updateProductNumByProductId(@Param("productId")Integer productId, @Param("productNum")Integer productNum);

    @Select("SELECT * FROM t_cl_product WHERE product_id = #{productId}")
    Product selectProductById(Integer productId);

    @Select("SELECT * FROM t_cl_product WHERE product_status = 0  order by product_name asc ")
    List<Product> listProductAll();




}